<html>
<title>SSC-SIS Analytics</title>
<head>
    <link rel="stylesheet" href="ssc_sis.css" type="text/css" media="screen" />
    <meta content="5" http-equiv="refresh"> 
    <style type="text/css">
        body { background: url("images/ssc_logo2.jpg"); }
    </style>        
</head>

<?php 
#call all includes below
    require_once('cls_config.php');  //data base connections and sessions are stored also
    include_once 'miscellaneous.php';
   // connection::start_session();
    include_once 'cls_forms.php';
    include_once 'cls_student.php';
    include_once 'cls_admin.php';



?>
<?php
  $query = sql_functions::select_query("* from session_table where data<>''");
  $users = sql_functions::fetch_to_array($query);
  ?>
  <center>
          <center><h1>Dashboard For SSC Student Information System</h1></center>
          <center>
              <table>
                <tr><td>Active Users</td><td><?php echo sql_functions::count_rows($query);?></td></tr>
              </table>
          </center>
          <hr>
  <?php
  if(sql_functions::count_rows($query)!=0){
      ?>
       <center>
          <table class="border_all">
            <tr class="title"><td>Username</td><td>Page Visited</td></tr>  
            <?php 
                foreach($users as $user){
                    ?>   
                    <tr><td><?php echo miscellaneous::load_session($user['data'],"username");?></td><td><?php echo miscellaneous::load_session($user['data'],"page");?></td></tr>
                    <?php
                }
            ?>
          </table>
          </center>
      
      <?php      
  }
  ?>
  <hr>
  <table>
    <tr>
  <?php 
  foreach($users as $user){
      
      $username= miscellaneous::load_session($user['data'],"username");
      ?>
      <td style="vertical-align: top;">
                <table class="border_all">
                     <tr class="title"><td>Logs of <?php echo miscellaneous::load_session($user['data'],"name");?></td></tr>
                          <?php
                          $ginagawa = sql_functions::select_query("* from logs_event where username='".$username."' and adlaw='".date('Y-m-d')."' order by id desc limit 1");
                          $row = sql_functions::fetch_to_array($ginagawa);
                          $data = miscellaneous::view_log_event($row[0]['ginagawa'],"ginagawa",30);
                          foreach($data as $datum){
                            ?>
                            <tr><td style="text-align: left"><?php echo $datum;?></td></tr>
                            <?php
                          }
                          ?> 
             </table> 
      
      </td>
      <?php
  }
  ?>
    </tr>
  </table>
            
</center>  
  <?php
?>
</html>